<template>
  <a-card :bordered="false" class="card-area" style="width: 80%">
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="学号"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.xh }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动类型"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select @change="ydlbChange" v-decorator="['ydlbm',{
                rules: [{ required: true, message: '请选择异动类型!' }],
              }]" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in TYPE0070.filter(a => a.code !== '60')" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>

        <!-- <a-col v-if="ydlbm == 60" :md="12" :sm="24">
          <a-form-item
            label="延长学习年限"
          >
            <a-select v-decorator="['ycnx',{
                rules: [{ required: true, message: '请选择延长学习年限!' }],
              }]">
              <a-select-option value="0.5">0.5</a-select-option>
              <a-select-option value="1">1</a-select-option>
              <a-select-option value="1.5">1.5</a-select-option>
              <a-select-option value="2">2</a-select-option>
              <a-select-option value="2.5">2.5</a-select-option>
              <a-select-option value="3">3</a-select-option>
            </a-select>
          </a-form-item>
        </a-col> -->
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动日期"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-date-picker v-decorator="['ydrq',{
                rules: [{ required: true, message: '请选择异动日期!' }],
              }]" style="width: 100%" />
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动原因"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="['ydyym']" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in selectMenu.ydyy" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="姓名"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yxm }}
            <!-- <a-input v-decorator="['yxm']" disabled></a-input> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后姓名"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input :disabled="xxmDisabled" v-decorator="['xxm']"></a-input>
            <!-- {{ transferInfo.xxm }} -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="性别"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yxbmc }}
            <!-- <a-select v-decorator="['yxbm']" disabled>
              <a-select-option v-for="i in TYPE0011" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后性别"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xxbDisabled" v-decorator="['xxbm']">
              <a-select-option v-for="i in TYPE0011" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="出生日期"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ycsrq && transferInfo.ycsrq.format('YYYY-MM-DD') }}
            <!-- <a-date-picker disabled v-decorator="['ycsrq']" style="width: 100%" /> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后出生日期"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-date-picker :disabled="xcsrqDisabled" v-decorator="['xcsrq']" style="width: 100%" />
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="证件类型"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yzjlxmc }}
            <!-- <a-select v-decorator="['yzjlxm']" disabled>
              <a-select-option v-for="i in TYPE0088" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后证件类型"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xzjlxmDisabled" v-decorator="['xzjlxm']">
              <a-select-option v-for="i in TYPE0088" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="证件号码"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yzjhm }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后证件号码"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input :disabled="xzjhmDisabled" v-decorator="['xzjhm']" maxLength="18"></a-input>
            <!-- {{ transferInfo.xzjhm }} -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前院系"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yyxsmc }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后院系"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xyxshDisabled" @change="yxChange" showSearch :filterOption="filterOption" v-decorator="['xyxsh']">
              <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwh }} {{ i.dwmc }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前专业"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yzymc }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后专业"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xzyhDisabled" @change="zyChange" v-decorator="['xzyh']" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in selectMenu.xzy" :key="i.id" :value="i.zyh">{{ i.zyh}} {{ i.zymc }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前导师"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ydsmc }}
            <!-- <a-select v-decorator="['ydsbm']" showSearch :filterOption="filterOption" disabled>
              <a-select-option v-for="i in tutor" :key="i.id" :value="i.dsbh">{{ i.dsbh }}{{ i.xm }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后导师"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xdsmDisabled" placeholder="请先选择院系和专业" v-decorator="['xdsm']" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in selectMenu.tutor" :key="i.id" :value="i.dsbh">{{ i.dsbh }}{{ i.xm }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前第二导师"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ydedsmc }}
            <!-- <a-select v-decorator="['ydedsm']" showSearch :filterOption="filterOption" disabled>
              <a-select-option v-for="i in tutor" :key="i.id" :value="i.dsbh">{{ i.dsbh }}{{ i.xm }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后第二导师"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xdedsmDisabled" placeholder="请先选择院系和专业"  v-decorator="['xdedsm']" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in selectMenu.tutor" :key="i.id" :value="i.dsbh">{{ i.dsbh }}{{ i.xm }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前培养层次"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ypyccmc }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后培养层次"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xpyccDisabled" v-decorator="['xpycc']">
              <a-select-option v-for="i in TYPE0310" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前学制"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yxz }}
            <!-- <a-select v-decorator="['yxz']" disabled>
              <a-select-option v-for="i in TYPE0301" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后学制"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xxzDisabled" v-decorator="['xxz']" @change="xzChange">
              <a-select-option v-for="i in TYPE0301" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前学籍状态"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.yxjztmc }}
            <!-- <a-select v-decorator="['yxjzt']" disabled>
              <a-select-option v-for="i in TYPE0073" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后学籍状态"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xxjztDisabled" v-decorator="['xxjzt']">
              <a-select-option v-for="i in TYPE0073" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="当前所在年级"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ynj }}
            <!-- <a-select v-decorator="['ynj']" disabled>
              <a-select-option v-for="i in TYPE0126" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select> -->
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后所在年级"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xnjDisabled" v-decorator="['xnj']">
              <a-select-option v-for="i in TYPE0126" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动前毕业年月"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            {{ transferInfo.ybyny && transferInfo.ybyny.format('YYYY-MM-DD') }}
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="异动后毕业年月"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select :disabled="xbynyDisabled" v-decorator="['xbyny']" allowClear  showSearch :filterOption="filterOption">
              <a-select-option v-for="i in graduateYearList" :key="i" :value="i">{{i}}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="24" :sm="48">
          <a-form-item label="异动备注" :labelCol="{span: 3,offset: 1}" :wrapperCol="{span: 15}">
            <a-input type="textarea" v-decorator="['note',
            {
              rules: [{ required: true, message: '请填写异动备注!' }]
            }]" :autosize="{ minRows: 4, maxRows: 6 }"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row style="text-align:center">
        <a-button :loading="loading" type="primary" @click="saveForm">保存并提交</a-button>
        <a-button style="margin-right: 20px;" @click="back()">返回</a-button>
      </a-row>
    </a-form>
  </a-card>
</template>
<script>
import { mapState } from 'vuex'
import moment from 'moment'
import ACol from "ant-design-vue/es/grid/Col";
import { debounce } from 'utils/common'

export default {
  components: {ACol},
  data () {
    return {
      queryForm: {},
      transferInfo: {},
      ydlbm: 0,
      selectMenu: {},
      loading: false,
      graduateYearList: [],
      xxmDisabled:false,
      xxbDisabled:false,
      xcsrqDisabled:false,
      xzjlxmDisabled:true,
      xzjhmDisabled:true,
      xyxshDisabled:false,
      xzyhDisabled:false,
      xdsmDisabled:false,
      xdedsmDisabled:false,
      xpyccDisabled:false,
      xxzDisabled: false,
      xxjztDisabled:false,
      xnjDisabled: false,
      xbynyDisabled: false
    }
  },
  computed: {
    ...mapState({
      TYPE0070: state => state.app['TYPE0070'], // 异动类型
      TYPE0302: state => state.app['TYPE0302'], // 异动原因
      TYPE0011: state => state.app['TYPE0011'], // 性别
      TYPE0088: state => state.app['TYPE0088'], // 证件类型
      TYPE0310: state => state.app['TYPE0310'], // 培养层次
      TYPE0301: state => state.app['TYPE0301'], // 学制
      TYPE0073: state => state.app['TYPE0073'], // 学籍状态
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    const curYear = new Date().getFullYear()
    function generateYearArray (start, end) {
      let arr = []
      let len = end - start
      for (let index = 0; index < len; index++) {
        arr.push(...[`${start + index}-07-01`,`${start + index}-12-31`])
      }
      return arr
    }
    this.graduateYearList = generateYearArray(curYear-100,curYear+20)
    this.initDictionary()
    if (this.$route.query.id) {
      this.$api.student.transferingInfoById(this.$route.query.id).then(res => {
        // this.ydlbm = res.data.ydlbm
        this.$set(this.queryForm, 'xh', res.data.xh)
        this.initSelectMenu()
        this.transferInfo = res.data
        for (const key in res.data) {
          if (['xcsrq', 'xbyny', 'ydrq'].includes(key)) {
            res.data[key] = moment(res.data[key])
          }
        }
        // res.data.ydyym = +res.data.ydyym
        if (res.data.xyxsh) {
          this.$api.base.majorAll({lsdwh: res.data.xyxsh}).then(res => {
            this.$set(this.selectMenu, 'xzy', res.data)
          })
          this.$api.student.tutorByStu({yxm: res.data.xyxsh, zym: res.data.xzyh}).then(res => {
            this.$set(this.selectMenu, 'tutor', res.data)
          })
        }
        if (res.data.xbyny) {
          res.data.xbyny = res.data.xbyny.format('YYYY-MM-DD')
        }
        this.$nextTick(() => {
          this.form.setFieldsValue(res.data)
          if (res.data.xyxsh) {
            this.yxChange(res.data.xyxsh)
          }
          if (res.data.ydlbm) {
            this.ydlbChange(res.data.ydlbm, true)
          }
        })
      })
    }
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  methods: {
    initDictionary () {
      this.$store.dispatch('app/setDictionary', 'TYPE0070')
      this.$store.dispatch('app/setDictionary', 'TYPE0302')
      this.$store.dispatch('app/setDictionary', 'TYPE0011')
      this.$store.dispatch('app/setDictionary', 'TYPE0088')
      this.$store.dispatch('app/setDictionary', 'TYPE0310')
      this.$store.dispatch('app/setDictionary', 'TYPE0301')
      this.$store.dispatch('app/setDictionary', 'TYPE0073')
      this.$store.dispatch('app/setDictionary', 'TYPE0126')
    },
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll()
      ]
      Promise.all(allRequest).then(res => {
        this.$set(this.selectMenu, 'yx', res[0].data)
      })
    },
    searchInfo () {
      this.$api.student.transferingInfo(this.queryForm.xh).then(res => {
        this.transferInfo = res.data
      })
    },
    filterOption (value, op) {
      return op.componentOptions.children[0].text.indexOf(value) !== -1
    },
    fetchYdyy: debounce(async function (typeCode) {
      if(typeCode && typeCode.length > 1){
        let { data } = await this.$api.dict.queryAll({
          typeCode: typeCode
        })
        this.$set(this.selectMenu, 'ydyy', data)
      }
    }),
    ydlbChange(code, init = false){
      this.form.setFieldsValue({
        ydyym:''
        // xxm:'',
        // xxb:'',
        // xcsrq:'',
        // xzjlxm:'',
        // xzjhm:'',
        // xyxsh:'',
        // xzyh:'',
        // xdsm:'',
        // xdedsm:'',
        // xpycc:'',
        // xxz: '',
        // xxjzt:'',
        // xnj: '',
        // xbyny: ''
      })
      this.form.setFieldsValue(this.transferInfo)
      this.xxmDisabled = false
      this.xxbDisabled = false
      this.xcsrqDisabled = false
      this.xzjlxmDisabled = false
      this.xzjhmDisabled = false
      this.xyxshDisabled = false
      this.xzyhDisabled = false
      this.xdsmDisabled = false
      this.xdedsmDisabled = false
      this.xpyccDisabled = false
      this.xxzDisabled =  false
      this.xxjztDisabled = false
      this.xnjDisabled =  false
      this.xbynyDisabled =  false
      switch(Number(code)){
        case 1: {
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '13'})
          break
        }
        case 6:{
          this.fetchYdyy('TYPE0433')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '3'})
          break
        }
        case 11: {
          this.fetchYdyy('TYPE0431')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '2'})
          break
        }
        case 12:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 14:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '12'})
          break
        }
        case 15:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '99'})
          break
        }
        case 16:{
          this.fetchYdyy('TYPE0432')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '16'})
          break
        }
        case 17:{
          this.fetchYdyy('TYPE0432')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '17'})
          break
        }
        case 18:{
          this.fetchYdyy('TYPE0432')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '18'})
          break
        }
        case 21:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '10'})
          break
        }
        case 22:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 23:{
          this.fetchYdyy('TYPE0302')
          this.xxmDisabled = true
          this.xcsrqDisabled = true
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xyxshDisabled = true
          this.xpyccDisabled = true
          this.xxzDisabled = true
          this.xxjztDisabled = true
          this.xnjDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 42:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '14'})
          break
        }
        case 43:{
          this.fetchYdyy('TYPE0440')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '17'})
          break
        }
        case 51:{
          this.fetchYdyy('TYPE0434')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '11'})
          break
        }
        case 60:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 62:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.form.setFieldsValue({xxjzt: '8'})
          break
        }
        case 64:{
          this.fetchYdyy('TYPE0302')
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xbynyDisabled = true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 66:{
          this.fetchYdyy('TYPE0302')
          this.xxbDisabled = true
          this.xcsrqDisabled = true
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xyxshDisabled = true
          this.xzyhDisabled = true
          this.xdsmDisabled = true
          this.xdedsmDisabled = true
          this.xpyccDisabled = true
          this.xxzDisabled =  true
          this.xxjztDisabled = true
          this.xnjDisabled =  true
          this.xbynyDisabled =  true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 68:{
          this.fetchYdyy('TYPE0302')
          this.xxmDisabled = true
          this.xxbDisabled = true
          this.xcsrqDisabled = true
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xyxshDisabled = true
          this.xzyhDisabled = true
          this.xdsmDisabled = true
          this.xdedsmDisabled = true
          this.xpyccDisabled = true
          this.xxzDisabled =  true
          this.xxjztDisabled = true
          this.xnjDisabled =  true
          this.xbynyDisabled =  true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 30:{
          this.fetchYdyy('TYPE0302')
          this.xbynyDisabled =  true
          this.form.setFieldsValue({xxjzt: '30'})
          break
        }
        case 31:{
          this.fetchYdyy('TYPE0302')
          this.xbynyDisabled =  true
          this.form.setFieldsValue({xxjzt: '31'})
          break
        }
        case 32:{
          this.fetchYdyy('TYPE0302')
          this.xxmDisabled = true
          this.xxbDisabled = true
          this.xcsrqDisabled = true
          this.xzjlxmDisabled = true
          this.xzjhmDisabled = true
          this.xyxshDisabled = true
          this.xzyhDisabled = true
          this.xdsmDisabled = true
          this.xdedsmDisabled = true
          this.xpyccDisabled = true
          this.xxjztDisabled = true
          this.xnjDisabled =  true
          this.form.setFieldsValue({xxjzt: '1'})
          break
        }
        case 99:{
          this.fetchYdyy('TYPE0302')
          this.xbynyDisabled =  true
          this.form.setFieldsValue({xxjzt: '99'})
          break
        }
      }
    },
    xzChange (code) {
      if (!this.transferInfo.xh) {
        return
      }
      if(!this.transferInfo.rxny){
        return
      }
      // const y = +this.transferInfo.rxny.format('YYYY')
      // const m = +this.transferInfo.rxny.format('MM')
      // const d = this.transferInfo.rxny.format('DD')
      // const addYear = +code.split('.')[0]
      // const addMonth = +code.split('.')[1] ? 6 : 0
      // let byYear = y + addYear
      // let byMonth
      // if (m + addMonth > 12) {
      //   byMonth = m + addMonth - 12 > 9 ? '0' + (m + addMonth - 12) : m + addMonth - 12
      //   ++byYear
      // } else {
      //   byMonth = m + addMonth > 9 ? m + addMonth : '0' + (m + addMonth)
      // }
      const y = +this.transferInfo.rxny.format('YYYY')
      let byYear = y
      let byMonth = '07'
      let byD = '01'
      switch(code){
        case '2':{
          byYear = y + 2
          byMonth = '07'
          byD = '01'
          break;
        }
        case '2.5':{
          byYear = y + 2
          byMonth = '12'
          byD = '31'
          break;
        }
        case '3':{
          byYear = y + 3
          byMonth = '07'
          byD = '01'
          break;
        }
        case '4':{
          byYear = y + 4
          byMonth = '07'
          byD = '01'
          break;
        }
      }
      this.form.setFieldsValue({xbyny: `${byYear}-${byMonth}-${byD}`})
      // if (code.) {
      //   xbyny = `${(+ybyny.split('-')[0] + Number(code))}${this.transferInfo.ybyny.format('-MM-DD')}`
      // }
    },
    yxChange (code) {
      this.form.setFieldsValue({sszym: ''})
      if (code) {
        this.$api.base.majorAll({lsdwh: code}).then(res => {
          this.$set(this.selectMenu, 'xzy', res.data)
        })
      } else {
        this.$set(this.selectMenu, 'xzy', [])
      }
    },
    zyChange(code) {
      this.form.setFieldsValue({xdsm: '', xdedsm: ''})
      this.$api.student.tutorByStu({yxm: this.form.getFieldValue('xyxsh'), zym: code}).then(res => {
        this.$set(this.selectMenu, 'tutor', res.data)
      })
    },
    saveForm () {
      if (!this.transferInfo.xh) {
        return this.$message.error('请先选择要修改的学籍')
      }
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        this.loading = true
        let params = Object.assign({}, this.transferInfo, values, {xjydId: this.$route.query.id})
        this.$DateToString(params)
        // for (const key in values) {
        //   if (['xcsrq', 'xbyny', 'ydrq'].includes(key) && values[key]) {
        //     params[key] = values[key].format('YYYY-MM-DD hh:mm:ss')
        //   }
        // }
        this.$api.student.transferingSave(params).then(res => {
          this.$message.success(res.msg)
          this.back()
        }).finally(() => {
          this.loading = false
        })
      })
    },
    back(){
      this.form.resetFields()
      this.$router.back()
    }
  }
}
</script>
